package controller;

import entity.ScholarshipApplications;
import service.ScholarshipApplicationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/scholarshipapplications")
public class ScholarshipApplicationsController {

    @Autowired
    private ScholarshipApplicationsService scholarshipApplicationsService;

    @GetMapping("/{id}")
    public ScholarshipApplications getById(@PathVariable Integer id) {
        return scholarshipApplicationsService.getById(id);
    }

    @GetMapping("/student/{studentId}")
    public List<ScholarshipApplications> getByStudentId(@PathVariable Integer studentId) {
        return scholarshipApplicationsService.getByStudentId(studentId);
    }

    @GetMapping("/all")
    public List<ScholarshipApplications> getAll() {
        return scholarshipApplicationsService.getAll();
    }

    @PostMapping
    public int create(@RequestBody ScholarshipApplications obj) {
        return scholarshipApplicationsService.create(obj);
    }

    @PutMapping
    public int update(@RequestBody ScholarshipApplications obj) {
        return scholarshipApplicationsService.update(obj);
    }

    @DeleteMapping("/{id}")
    public int delete(@PathVariable Integer id) {
        return scholarshipApplicationsService.delete(id);
    }
}